import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)


// const iac2 = uni.createInnerAudioContext()
const store = new Vuex.Store({
	state: {
		playState: false,
		playMethod: 1,
		nextPlay:{
			nowListIndex: 0,
			nowSongIndex: 0,
		},
		song:{// 用来存储当前播放的歌曲
			id: 1474342935,
			image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
			url: "http://m8.music.126.net/20210601201227/d693243518c323b90d4a11cffcfa3e89/ymusic/560b/060e/5359/aa1ab79b911dbac1cafcd3ecc539dcb6.mp3",
			// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
			author: '',
			title: '',
			lyric: ''
		},
		lists:[
			{
				name: '古风',
				type: '最近播放',
				lists: [{id: 1474342935,
						image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
						url: "",
						// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
						author: '',
						title: '',
						lyric: ''},
						{id: 33556500,
						image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
						url: "",
						// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
						author: '',
						title: '',
						lyric: ''},{
							id: 32102071,
							image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
							url: "",
							// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
							author: '',
							title: '',
							lyric: ''
						}]
			},
			{
				name: '古风',
				type: '爱情',
				lists: [{id: 1474342935,
						image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
						url: "",
						// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
						author: '',
						title: '',
						lyric: ''},
						{id: 33556500,
						image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
						url: "",
						// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
						author: '',
						title: '',
						lyric: ''}]
			},
			{
				name: 'taylor',
				type: 'taylor swift',
				lists: [{id: 32102071,
						image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
						url: "",
						// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
						author: '',
						title: '',
						lyric: ''},
						{id: 1474342935,
						image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
						url: "",
						// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
						author: '',
						title: '',
						lyric: ''}]
			},
			
		],
		
		
	},
	mutations: {
		songChange(state, provider){
			// provider:{// 用来存储当前播放的歌曲
			// 	id: 1474342935,
			// 	image: 'https://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg',
			// 	url: "",
			// 	// url: 'http://m7.music.126.net/20200920221019/d64e8d21503b3b45e7637e29c06583bd/ymusic/obj/w5zDlMODwrDDiGjCn8Ky/3045976692/8720/40bf/be20/679b48e199208b54539ff50695771e98.mp3',
			// 	author: '',
			// 	title: '',
			// 	lyric: ''
			// }
			state.song.id= provider.id
			state.song.image = provider.image || 'https://img.zcool.cn/community/01deed576019060000018c1bd2352d.gif'
			state.song.url = provider.url
			state.song.author = provider.author || '未知'
			state.song.title = provider.title || '未知'
		},
		// 列表改变,列表删除、列表添加、列表、修改。
		listChange(state, provider){
			// provider:{
			// 	type: String,
			// 	songList: [song,{}],
			// }
			state.lists = provider.lists;
		},
		// 歌曲播放状态改变
		nowPlayChange(state, provider){
			// console.log("nowSongChange", provider)
			state.playMethod = provider.playMethod || state.playMethod;
			state.playState = provider.playState || false;
			
			// console.log("state=======", state)
		},
		nowSongChange(state, provider){
			// console.log('provider',provider)
			state.nextPlay.nowSongIndex = provider.nowSongIndex;
			state.nextPlay.nowListIndex = provider.nowListIndex ;
			// console.log( 'state.nextPlay',state.nextPlay)
		}

	},
	getters: {
		songData: state=>{
			return state.song
		},
		playData: state=>{
			return {
				playState: state.playState,
				playMethod: state.playMethod,
			}
		},
		nextPlayData: state=>{return state.nextPlay},
		listData: state=>{return state.lists}
	}
})
export default store